Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

#2859 Support changing format inside entity #2896

Merged
merged 4 commits into from
Dec 9, 2024
Merged

Conversation

JiuqingSong
Copy link
Collaborator

@JiuqingSong JiuqingSong commented Nov 29, 2024

This change is to support changing format inside an entity.

Not like normal content, entity is owned by its creator (normally a plugin), so our format code will skip all entity and keep it not changed. However, some requirements come and they want some of the entity content can also be formatted. So in this change I added a new entity operation beforeFormat, it will be triggered when formatSegmentWithContentModel is called, this is used by most of the segment format APIs such as toggleBold and setTextColor.

Plugin can handle entityOperation event and check the entity type and id, then put the root element of content that you want to format into formattableRoots property of this event object. After that roosterjs will create content model for each root and do format changes.

There is a sample change in SampleEntityPlugin.ts in this PR that shows how to use this event.

@JiuqingSong JiuqingSong marked this pull request as ready for review December 2, 2024 23:37
@JiuqingSong JiuqingSong merged commit 334e038 into master Dec 9, 2024
7 checks passed
@JiuqingSong JiuqingSong deleted the u/jisong/2859 branch December 9, 2024 19:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants